/*
** size_file.c for corewar in /home/rajaon_m//corewar
**
** Made by maryse rajaonary
** Login   <rajaon_m@epitech.net>
**
** Started on  Thu Feb 16 10:18:28 2012 maryse rajaonary
** Last update Thu Feb 16 12:47:02 2012 moustafa boulahia
*/

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include "my.h"
int	size_file(int fd)
{
  int	size;
  int	rd;
  char	buffer[4096];

  size = 0;
  rd = read(fd, buffer, 4096);
  check_read(rd);
  while (rd != 0)
    {
      size = size + rd;
      rd = read(fd, buffer, 4096);
      check_read(rd);
    }
  lseek(fd, SEEK_SET, 0);
  return (size);
}
